package com.yunzan.sync_netty.server;

import java.util.List;


import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.string.StringEncoder;

public class HexEncoder extends StringEncoder {

	@Override
	protected void encode(ChannelHandlerContext ctx, CharSequence msg, List<Object> out) throws Exception {
		System.out.println("传输 "+msg.toString());
		ByteBuf bufff = Unpooled.buffer();//netty需要用ByteBuf传输
     	
		//bufff.writeBytes(Hex.hexToByteArray(msg.toString()));//对接需要16进制
		//bufff.writeBytes(Hex.hexStr2Bytes(msg.toString()));
		bufff.writeBytes(msg.toString().getBytes());
		out.add(bufff);
		
	}
	
	

}
